home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Speech.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  14KB  |  407 lines

  1. /*
  2.      File:        Speech.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __SPEECH__
  19. #define __SPEECH__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  44.  
  45. enum {
  46.     kTextToSpeechSynthType        = 'ttsc',
  47.     kTextToSpeechVoiceType        = 'ttvd',
  48.     kTextToSpeechVoiceFileType    = 'ttvf',
  49.     kTextToSpeechVoiceBundleType = 'ttvb'
  50. };
  51.  
  52.  
  53. enum {
  54.     kNoEndingProsody            = 1,
  55.     kNoSpeechInterrupt            = 2,
  56.     kPreflightThenPause            = 4
  57. };
  58.  
  59.  
  60. enum {
  61.     kImmediate                    = 0,
  62.     kEndOfWord                    = 1,
  63.     kEndOfSentence                = 2
  64. };
  65.  
  66. /*------------------------------------------*/
  67. /* GetSpeechInfo & SetSpeechInfo selectors    */
  68. /*------------------------------------------*/
  69.  
  70. enum {
  71.     soStatus                    = 'stat',
  72.     soErrors                    = 'erro',
  73.     soInputMode                    = 'inpt',
  74.     soCharacterMode                = 'char',
  75.     soNumberMode                = 'nmbr',
  76.     soRate                        = 'rate',
  77.     soPitchBase                    = 'pbas',
  78.     soPitchMod                    = 'pmod',
  79.     soVolume                    = 'volm',
  80.     soSynthType                    = 'vers',
  81.     soRecentSync                = 'sync',
  82.     soPhonemeSymbols            = 'phsy',
  83.     soCurrentVoice                = 'cvox',
  84.     soCommandDelimiter            = 'dlim',
  85.     soReset                        = 'rset',
  86.     soCurrentA5                    = 'myA5',
  87.     soRefCon                    = 'refc',
  88.     soTextDoneCallBack            = 'tdcb',
  89.     soSpeechDoneCallBack        = 'sdcb',
  90.     soSyncCallBack                = 'sycb',
  91.     soErrorCallBack                = 'ercb',
  92.     soPhonemeCallBack            = 'phcb',
  93.     soWordCallBack                = 'wdcb',
  94.     soSynthExtension            = 'xtnd',
  95.     soSoundOutput                = 'sndo'
  96. };
  97.  
  98. /*------------------------------------------*/
  99. /* Speaking Mode Constants                     */
  100. /*------------------------------------------*/
  101.  
  102. enum {
  103.     modeText                    = 'TEXT',                        /* input mode constants                     */
  104.     modePhonemes                = 'PHON',
  105.     modeNormal                    = 'NORM',                        /* character mode and number mode constants */
  106.     modeLiteral                    = 'LTRL'
  107. };
  108.  
  109.  
  110. enum {
  111.     soVoiceDescription            = 'info',
  112.     soVoiceFile                    = 'fref'
  113. };
  114.  
  115. struct SpeechChannelRecord {
  116.     long                             data[1];
  117. };
  118. typedef struct SpeechChannelRecord SpeechChannelRecord;
  119.  
  120. typedef SpeechChannelRecord *SpeechChannel;
  121. struct VoiceSpec {
  122.     OSType                             creator;
  123.     OSType                             id;
  124. };
  125. typedef struct VoiceSpec VoiceSpec;
  126.  
  127.  
  128. enum {
  129.     kNeuter                        = 0,
  130.     kMale                        = 1,
  131.     kFemale                        = 2
  132. };
  133.  
  134. struct VoiceDescription {
  135.     long                             length;
  136.     VoiceSpec                         voice;
  137.     long                             version;
  138.     Str63                             name;
  139.     Str255                             comment;
  140.     short                             gender;
  141.     short                             age;
  142.     short                             script;
  143.     short                             language;
  144.     short                             region;
  145.     long                             reserved[4];
  146. };
  147. typedef struct VoiceDescription VoiceDescription;
  148.  
  149. struct VoiceFileInfo {
  150.     FSSpec                             fileSpec;
  151.     short                             resID;
  152. };
  153. typedef struct VoiceFileInfo VoiceFileInfo;
  154.  
  155. struct SpeechStatusInfo {
  156.     Boolean                         outputBusy;
  157.     Boolean                         outputPaused;
  158.     long                             inputBytesLeft;
  159.     short                             phonemeCode;
  160. };
  161. typedef struct SpeechStatusInfo SpeechStatusInfo;
  162.  
  163. struct SpeechErrorInfo {
  164.     short                             count;
  165.     OSErr                             oldest;
  166.     long                             oldPos;
  167.     OSErr                             newest;
  168.     long                             newPos;
  169. };
  170. typedef struct SpeechErrorInfo SpeechErrorInfo;
  171.  
  172. struct SpeechVersionInfo {
  173.     OSType                             synthType;
  174.     OSType                             synthSubType;
  175.     OSType                             synthManufacturer;
  176.     long                             synthFlags;
  177.     NumVersion                         synthVersion;
  178. };
  179. typedef struct SpeechVersionInfo SpeechVersionInfo;
  180.  
  181. struct PhonemeInfo {
  182.     short                             opcode;
  183.     Str15                             phStr;
  184.     Str31                             exampleStr;
  185.     short                             hiliteStart;
  186.     short                             hiliteEnd;
  187. };
  188. typedef struct PhonemeInfo PhonemeInfo;
  189.  
  190. struct PhonemeDescriptor {
  191.     short                             phonemeCount;
  192.     PhonemeInfo                     thePhonemes[1];
  193. };
  194. typedef struct PhonemeDescriptor PhonemeDescriptor;
  195.  
  196. struct SpeechXtndData {
  197.     OSType                             synthCreator;
  198.     Byte                             synthData[2];
  199. };
  200. typedef struct SpeechXtndData SpeechXtndData;
  201.  
  202. struct DelimiterInfo {
  203.     Byte                             startDelimiter[2];
  204.     Byte                             endDelimiter[2];
  205. };
  206. typedef struct DelimiterInfo DelimiterInfo;
  207.  
  208. typedef pascal void (*SpeechTextDoneProcPtr)(SpeechChannel parameter0, long parameter1, Ptr *parameter2, long *parameter3, long *parameter4);
  209. typedef pascal void (*SpeechDoneProcPtr)(SpeechChannel parameter0, long parameter1);
  210. typedef pascal void (*SpeechSyncProcPtr)(SpeechChannel parameter0, long parameter1, OSType parameter2);
  211. typedef pascal void (*SpeechErrorProcPtr)(SpeechChannel parameter0, long parameter1, OSErr parameter2, long parameter3);
  212. typedef pascal void (*SpeechPhonemeProcPtr)(SpeechChannel parameter0, long parameter1, short parameter2);
  213. typedef pascal void (*SpeechWordProcPtr)(SpeechChannel parameter0, long parameter1, long parameter2, short parameter3);
  214.  
  215. #if GENERATINGCFM
  216. typedef UniversalProcPtr SpeechTextDoneUPP;
  217. typedef UniversalProcPtr SpeechDoneUPP;
  218. typedef UniversalProcPtr SpeechSyncUPP;
  219. typedef UniversalProcPtr SpeechErrorUPP;
  220. typedef UniversalProcPtr SpeechPhonemeUPP;
  221. typedef UniversalProcPtr SpeechWordUPP;
  222. #else
  223. typedef SpeechTextDoneProcPtr SpeechTextDoneUPP;
  224. typedef SpeechDoneProcPtr SpeechDoneUPP;
  225. typedef SpeechSyncProcPtr SpeechSyncUPP;
  226. typedef SpeechErrorProcPtr SpeechErrorUPP;
  227. typedef SpeechPhonemeProcPtr SpeechPhonemeUPP;
  228. typedef SpeechWordProcPtr SpeechWordUPP;
  229. #endif
  230.  
  231. enum {
  232.     uppSpeechTextDoneProcInfo = kPascalStackBased
  233.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  234.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  235.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr *)))
  236.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long *)))
  237.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long *))),
  238.     uppSpeechDoneProcInfo = kPascalStackBased
  239.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  240.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))),
  241.     uppSpeechSyncProcInfo = kPascalStackBased
  242.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  243.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  244.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType))),
  245.     uppSpeechErrorProcInfo = kPascalStackBased
  246.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  247.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  248.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSErr)))
  249.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  250.     uppSpeechPhonemeProcInfo = kPascalStackBased
  251.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  252.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  253.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short))),
  254.     uppSpeechWordProcInfo = kPascalStackBased
  255.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  256.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  257.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  258.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  259. };
  260.  
  261. #if GENERATINGCFM
  262. #define NewSpeechTextDoneProc(userRoutine)        \
  263.         (SpeechTextDoneUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  264. #define NewSpeechDoneProc(userRoutine)        \
  265.         (SpeechDoneUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  266. #define NewSpeechSyncProc(userRoutine)        \
  267.         (SpeechSyncUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  268. #define NewSpeechErrorProc(userRoutine)        \
  269.         (SpeechErrorUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  270. #define NewSpeechPhonemeProc(userRoutine)        \
  271.         (SpeechPhonemeUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  272. #define NewSpeechWordProc(userRoutine)        \
  273.         (SpeechWordUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  274. #else
  275. #define NewSpeechTextDoneProc(userRoutine)        \
  276.         ((SpeechTextDoneUPP) (userRoutine))
  277. #define NewSpeechDoneProc(userRoutine)        \
  278.         ((SpeechDoneUPP) (userRoutine))
  279. #define NewSpeechSyncProc(userRoutine)        \
  280.         ((SpeechSyncUPP) (userRoutine))
  281. #define NewSpeechErrorProc(userRoutine)        \
  282.         ((SpeechErrorUPP) (userRoutine))
  283. #define NewSpeechPhonemeProc(userRoutine)        \
  284.         ((SpeechPhonemeUPP) (userRoutine))
  285. #define NewSpeechWordProc(userRoutine)        \
  286.         ((SpeechWordUPP) (userRoutine))
  287. #endif
  288.  
  289. #if GENERATINGCFM
  290. #define CallSpeechTextDoneProc(userRoutine, parameter0, parameter1, parameter2, parameter3, parameter4)        \
  291.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, (parameter0), (parameter1), (parameter2), (parameter3), (parameter4))
  292. #define CallSpeechDoneProc(userRoutine, parameter0, parameter1)        \
  293.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechDoneProcInfo, (parameter0), (parameter1))
  294. #define CallSpeechSyncProc(userRoutine, parameter0, parameter1, parameter2)        \
  295.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechSyncProcInfo, (parameter0), (parameter1), (parameter2))
  296. #define CallSpeechErrorProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  297.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechErrorProcInfo, (parameter0), (parameter1), (parameter2), (parameter3))
  298. #define CallSpeechPhonemeProc(userRoutine, parameter0, parameter1, parameter2)        \
  299.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, (parameter0), (parameter1), (parameter2))
  300. #define CallSpeechWordProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechWordProcInfo, (parameter0), (parameter1), (parameter2), (parameter3))
  302. #else
  303. #define CallSpeechTextDoneProc(userRoutine, parameter0, parameter1, parameter2, parameter3, parameter4)        \
  304.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3), (parameter4))
  305. #define CallSpeechDoneProc(userRoutine, parameter0, parameter1)        \
  306.         (*(userRoutine))((parameter0), (parameter1))
  307. #define CallSpeechSyncProc(userRoutine, parameter0, parameter1, parameter2)        \
  308.         (*(userRoutine))((parameter0), (parameter1), (parameter2))
  309. #define CallSpeechErrorProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  310.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3))
  311. #define CallSpeechPhonemeProc(userRoutine, parameter0, parameter1, parameter2)        \
  312.         (*(userRoutine))((parameter0), (parameter1), (parameter2))
  313. #define CallSpeechWordProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  314.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3))
  315. #endif
  316. extern pascal NumVersion SpeechManagerVersion(void )
  317.  FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  318.  
  319. extern pascal OSErr MakeVoiceSpec(OSType creator, OSType id, VoiceSpec *voice)
  320.  FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  321.  
  322. extern pascal OSErr CountVoices(short *numVoices)
  323.  FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  324.  
  325. extern pascal OSErr GetIndVoice(short index, VoiceSpec *voice)
  326.  FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  327.  
  328. extern pascal OSErr GetVoiceDescription(VoiceSpec *voice, VoiceDescription *info, long infoLength)
  329.  FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  330.  
  331. extern pascal OSErr GetVoiceInfo(VoiceSpec *voice, OSType selector, void *voiceInfo)
  332.  FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  333.  
  334. extern pascal OSErr NewSpeechChannel(VoiceSpec *voice, SpeechChannel *chan)
  335.  FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  336.  
  337. extern pascal OSErr DisposeSpeechChannel(SpeechChannel chan)
  338.  FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  339.  
  340. extern pascal OSErr SpeakString(StringPtr s)
  341.  FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  342.  
  343. extern pascal OSErr SpeakText(SpeechChannel chan, Ptr textBuf, long textBytes)
  344.  FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  345.  
  346. extern pascal OSErr SpeakBuffer(SpeechChannel chan, Ptr textBuf, long textBytes, long controlFlags)
  347.  FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  348.  
  349. extern pascal OSErr StopSpeech(SpeechChannel chan)
  350.  FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  351.  
  352. extern pascal OSErr StopSpeechAt(SpeechChannel chan, long whereToStop)
  353.  FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  354.  
  355. extern pascal OSErr PauseSpeechAt(SpeechChannel chan, long whereToPause)
  356.  FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  357.  
  358. extern pascal OSErr ContinueSpeech(SpeechChannel chan)
  359.  FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  360.  
  361. extern pascal short SpeechBusy(void )
  362.  FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  363.  
  364. extern pascal short SpeechBusySystemWide(void )
  365.  FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  366.  
  367. extern pascal OSErr SetSpeechRate(SpeechChannel chan, Fixed rate)
  368.  FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  369.  
  370. extern pascal OSErr GetSpeechRate(SpeechChannel chan, Fixed *rate)
  371.  FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  372.  
  373. extern pascal OSErr SetSpeechPitch(SpeechChannel chan, Fixed pitch)
  374.  FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  375.  
  376. extern pascal OSErr GetSpeechPitch(SpeechChannel chan, Fixed *pitch)
  377.  FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  378.  
  379. extern pascal OSErr SetSpeechInfo(SpeechChannel chan, OSType selector, void *speechInfo)
  380.  FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  381.  
  382. extern pascal OSErr GetSpeechInfo(SpeechChannel chan, OSType selector, void *speechInfo)
  383.  FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  384.  
  385. extern pascal OSErr TextToPhonemes(SpeechChannel chan, Ptr textBuf, long textBytes, Handle phonemeBuf, long *phonemeBytes)
  386.  FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  387.  
  388. extern pascal OSErr UseDictionary(SpeechChannel chan, Handle dictionary)
  389.  FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  390.  
  391. #endif
  392.  
  393. #if PRAGMA_ALIGN_SUPPORTED
  394. #pragma options align=reset
  395. #endif
  396.  
  397. #if PRAGMA_IMPORT_SUPPORTED
  398. #pragma import off
  399. #endif
  400.  
  401. #ifdef __cplusplus
  402. }
  403. #endif
  404.  
  405. #endif /* __SPEECH__ */
  406.  
  407.